//
// Created by yunlang on 2021/12/21.
//
#include <iostream>
#include "FileIO.h"
#include "File.h"
using namespace std;
void menu()
{
    string command;
    const string SearchType = "t";
    const string SearchYear = "y";
    const string Quit = "q";
    cout << "Input your choice:(\"t\"for search type, \"y\"for search year,\"q\"for quit): " << endl;
    cin >> command;
    if (command == SearchType) {
        string filename;
        cout << "请输入文件名" << endl;
        cin >> filename;
        File *p = FileIO::readFr omFile(filename);
        p->getRate();
        getchar();
        getchar();
        system("clear");
    } else if (command == SearchYear) {
        string filename;
        cout << "请输入文件名" << endl;
        cin >> filename;
        File *p = FileIO::readFromFile(filename);
        p->getYear();
        getchar();
        getchar();
        system("clear");
    } else if (command == Quit) {
        exit(0);
    }else {
        cout << endl;
        cout << "Wrong Command!" << endl;
        getchar();
        getchar();
        system("clear");
    }
    menu();
}